home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / powerd / source / lib / chunky_lib.lha / Chunky / CopyChunky.ass < prev    next >
Encoding:
Text File  |  2000-08-03  |  1.7 KB  |  77 lines

  1. ; CopyChunky(dst:a0:PTR TO chunky,dx:d0:LONG,dy:d1:LONG,
  2. ;            src:a1:PTR TO chunky,sx:d2:LONG,sy:d3:LONG,
  3. ;            w:d4:LONG,h:d5:LONG)
  4.  
  5.     machine    mc68020
  6.  
  7.     xdef    _CopyChunky
  8. _CopyChunky
  9.     movem.l    d2-d7/a2-a3,-(a7)
  10.  
  11. ; DESTINATION BOUNDS
  12.     tst.l    d0        ; left bound
  13.     bge.s    .leftdone
  14.     move.l    d0,d7            ; store left negative offset
  15.     neg.l    d7
  16.     cmp.l    d4,d7
  17.     bge.s    .finish            ; out of bounds
  18.     moveq    #0,d0            ; left position
  19.     add.l    d7,d2
  20.     sub.l    d7,d4            ; new width
  21. .leftdone
  22.     tst.l    d1        ; top bound
  23.     bge.s    .topdone
  24.     move.l    d1,d7            ; store top negative offset
  25.     neg.l    d7
  26.     cmp.l    d5,d7
  27.     bge.s    .finish            ; out of bounds
  28.     moveq    #0,d1            ; top position
  29.     add.l    d7,d3
  30.     sub.l    d7,d5            ; new height
  31. .topdone
  32.     cmp.l    (a0),d0        ; right bound
  33.     bgt.s    .finish
  34.     move.l    (a0),d7            ; store maximal width
  35.     sub.l    d0,d7            ; change width
  36.     cmp.l    d4,d7            ; check if we can fit
  37.     bgt.s    .rightdone        ; we can fit
  38.     move.l    d7,d4            ; new width, we can't fit
  39. .rightdone
  40.     cmp.l    (4,a0),d1        ; bottom bound
  41.     bgt.s    .finish
  42.     move.l    (4,a0),d7            ; store maximal width
  43.     sub.l    d1,d7            ; change width
  44.     cmp.l    d5,d7            ; check if we can fit
  45.     bgt.s    .bottomdone        ; we can fit
  46.     move.l    d7,d5            ; new width, we can't fit
  47. .bottomdone
  48.  
  49.     move.l    (a0),d6        ; get dest width to d6
  50.     muls.l    d1,d6
  51.     add.l    d6,d0        ; now we have start position in dest buffer
  52.     move.l    (8,a0),a2
  53.     add.l    d0,a2
  54.  
  55.     move.l    (a1),d6
  56.     muls.l    d3,d6
  57.     add.l    d6,d2
  58.     move.l    (8,a1),a3
  59.     add.l    d2,a3        ; and start position in source buffer
  60.  
  61.     move.l    (a0),d2        ; get the d2 and d3 values
  62.     sub.l    d4,d2
  63.     move.l    (a1),d3
  64.     sub.l    d4,d3
  65.  
  66.     subq.l    #1,d4
  67.     subq.l    #1,d5
  68.     move.l    d4,d6        ; store width
  69. .loopy    move.l    d6,d4        ; restore width
  70. .loopx    move.b    (a3)+,(a2)+    ; copy pixel
  71.     dbra.s    d4,.loopx
  72.     adda.l    d2,a2
  73.     adda.l    d3,a3
  74.     dbra.s    d5,.loopy
  75. .finish    movem.l    (a7)+,d2-d7/a2-a3
  76.     rts
  77.